import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);

//封装的图表
const charts = () => import('@/views/charts.vue');

//学校详情
const schoolDetails = () => import('@/views/schoolDetails.vue');

//HJ区域数据图表
const hjcharts = () => import('@/views/homejunction/homejunction.vue');

//区域数据图表
const zipcodeCharts = () => import('@/views/zipcodeCharts/zipcodeCharts.vue');

//关于房租
const RentSituation = () => import('@/views/zillowCharts/RentSituation/RentSituation.vue');

//关于房价
const PriceSituation = () => import('@/views/zillowCharts/PriceSituation/PriceSituation.vue');

//贷款概况
const MortgageSituation = () => import('@/views/zillowCharts/MortgageSituation/MortgageSituation.vue');

//市场概况
const MarketSituation = () => import('@/views/zillowCharts/MarketSituation/MarketSituation.vue');

//地区概况
const RegionSituation = () => import('@/views/zillowCharts/RegionSituation/RegionSituation.vue');

//投资分析数据
const InvestmentAnalysisCharts = () => import('@/views/InvestmentAnalysisCharts/InvestmentAnalysisCharts.vue');

const routes = [
    {path: '/', component: charts, name: 'charts', meta: {keepAlive: false, title: '图表'}},//图表
    {path: '/schoolDetails', component: schoolDetails, name: 'schoolDetails', meta: {keepAlive: false, title: '学校详情'}},//学校详情
    {path: '/hjcharts', component: hjcharts, name: 'hjcharts', meta: {keepAlive: false, title: 'HJ区域数据图表'}},//HJ区域数据图表
    {path: '/zipcodeCharts', component: zipcodeCharts, name: 'zipcodeCharts', meta: {keepAlive: false, title: '区域数据图表'}},//区域数据图表
    {path: '/RentSituation', component: RentSituation, name: 'RentSituation', meta: {keepAlive: false, title: '关于房租'}},//关于房租
    {path: '/PriceSituation', component: PriceSituation, name: 'PriceSituation', meta: {keepAlive: false, title: '关于房价'}},//关于房价
    {path: '/MortgageSituation', component: MortgageSituation, name: 'MortgageSituation', meta: {keepAlive: false, title: '贷款概况'}},//贷款概况
    {path: '/MarketSituation', component: MarketSituation, name: 'MarketSituation', meta: {keepAlive: false, title: '市场概况'}},//市场概况
    {path: '/RegionSituation', component: RegionSituation, name: 'RegionSituation', meta: {keepAlive: false, title: '地区概况'}},//地区概况
    {path: '/InvestmentAnalysisCharts', component: InvestmentAnalysisCharts, name: 'InvestmentAnalysisCharts', meta: {keepAlive: false, title: '投资分析数据'}},//投资分析数据
];

//实例化router
const router = new VueRouter({
    routes,
    mode: 'history',
    //解决使用keep-alive后，第二个页面可能继承第一个页面的滚动条的高度
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            return {
                x: 0,
                y: 0
            }
        }
    }
});

// 导出router实例，main.js使用
export default router;
